import { Component, OnInit, DoCheck } from '@angular/core';

//toast
import { LoginComponent } from '../login/login.component';

// service
import { ConfigService } from '../config.service';
import { ToastComponent } from '../toast/toast.component';

//cookies
import { CookieService } from 'angular2-cookie/core';
declare var $: any;

@Component({
  selector: 'app-head',
  templateUrl: './head.component.html',
  styleUrls: ['./head.component.css'],
  providers: [ConfigService]
})

export class HeadComponent implements OnInit {

  type: string;
  is_login:any;
  msg:any;

  constructor() {
  }

  ngOnInit() {
    $('.button-collapse').sideNav({
      menuWidth: 300,
      edge: 'left',
      closeOnClick: true,
      draggable: true,
      onOpen: function (el) { },
      onClose: function (el) { }
    });
    $('.parallax').parallax();

  }

  showLogin() {
    this.type = 'login';
    $('#modal1').modal('open');
  }

  loginOut(){
    this.msg = '已退出登入';
    new CookieService().remove('is_login');
  }

  // 组件视图脏检查完成之后
  ngAfterViewChecked() {
    this.is_login = new CookieService().get('is_login');
  }

}
